import { Injectable } from '@angular/core'
import { HttpClientService } from 'src/app/common/httpClient/http'
import { CommonUtil } from 'src/app/common/utils/common.util'
import { CoolLocalStorage } from 'src/app/common/coolStorage/cool-local-storage'

@Injectable({
  providedIn: 'root'
})
export class ServiceCommentService {
  user = ''
  reqdata = {
    pager: { Start: 0, Limit: 10 },
    filter: {
      Lambda: '',
      Navigations: ['CategoryInfo']
    },
    sorters: [{ Property: 'item=>item.UpdateTime', Direction: 'Descending' }]
  }

  constructor(private http: HttpClientService, private utils: CommonUtil, private storage: CoolLocalStorage) {
    let userinfo = storage.getObject('userinfo')
    if (userinfo) {
      this.user = userinfo['Id']
    }
  }

  getList(Start, callback, errorBack?) {
    let code = 'InvitationStatus_Submit'
    let lambda = `item=>item.Receiver==${this.user}&&item.StatusInfo.Code="${code}"`
    this.reqdata.pager.Start = Start
    this.reqdata.filter.Lambda = lambda
    this.http.post(this.reqdata, '/House1/Json/InvitationService.svc/QueryInvitationSummary', callback, errorBack)
  }
}
